package com.cloudlinkscm.base.authcenter.controller;

import com.cloudlinkscm.base.authcenter.model.dto.TenantResourceDistributionDTO;
import com.cloudlinkscm.base.authcenter.model.dto.TenantResourceMoveDTO;
import com.cloudlinkscm.base.authcenter.service.TenantResourceService;
import com.cloudlinkscm.loms.framework.core.pojo.RestfulApiResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by sin on 2017/8/7.
 *
 * 租户权限：资源
 */
@RestController
public class TenantResourceController {

	@Autowired
	private TenantResourceService tenantResourceService;


	///
	/// 资源分配

	@ApiOperation("租户权限资源：获取（根据租户id）")
	@RequestMapping(value = "tenant_resource/{tenantId}", method = RequestMethod.GET)
	public RestfulApiResponse<TenantResourceDistributionDTO> resource(@PathVariable("tenantId") String tenantId) {
		return RestfulApiResponse.success(tenantResourceService.getResource(tenantId));
	}


	@ApiOperation("租户权限资源：移动节点（移入 跟 移除）")
	@RequestMapping(value = "tenant_resource/{tenantId}/move", method = RequestMethod.PUT)
	public RestfulApiResponse move(@PathVariable("tenantId") String tenantId,
	                               @RequestBody TenantResourceMoveDTO moveDTO) {
		return RestfulApiResponse.success(tenantResourceService.move(tenantId, moveDTO));
	}


	///
	/// 租户资源  暂不实行

//
//	@ApiOperation("租户资源：tree")
//	@RequestMapping(value = "tenant_resource/tree", method = RequestMethod.GET)
//	public RestfulApiResponse<ResourceTree> tree() {
//		return RestfulApiResponse.success(tenantResourceService.tree());
//	}
}
